package org.bleep.physics;

import org.bleep.util.DrawingUtils;
import org.bleep.geom.Rectangle;
import org.bleep.util.Color;

import org.lwjgl.opengl.GL11;

public class Particle
{
	private Vector2D position, oldPosition, forceAccumulator;
	private float mass;
	
	public Particle(Vector2D position, float mass)
	{
		this.position = position;
		this.mass = mass;
		forceAccumulator = new Vector2D(0f, 0f);
		oldPosition = new Vector2D(position.getX(), position.getY());
	}
	
	public void addForce(Vector2D force)
	{
		forceAccumulator.add(force);
	}
	
	public void update(float timeStep)
	{
		Vector2D temp = new Vector2D(position.getX(), position.getY());
		Vector2D delta = new Vector2D(position.getX(), position.getY());
		delta.sub(oldPosition);
		forceAccumulator.div(mass);
		forceAccumulator.mult(timeStep * timeStep);
		delta.add(forceAccumulator);
		position.add(delta);
		oldPosition = temp;
		
		forceAccumulator.zero();
	}
	
	public Vector2D getPosition()
	{
		return position;
	}
	
	public float getMass()
	{
		return mass;
	}
}